package com.dc.business.datacollectbusiness;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.security.MessageDigest;
@SpringBootTest
public class md5 {
    public static String md5(String input) {
        try {
            MessageDigest md=MessageDigest.getInstance("MD5");
            byte[] md5Bytes = md.digest(input.getBytes());

            StringBuilder hexString=new StringBuilder();
            for (byte md5Byte : md5Bytes) {
                String hex=Integer.toHexString(md5Byte & 0xff);
                if(hex.length()==1) {
                    hexString.append('0');
                }
                hexString.append(hex);
            }
            return hexString.toString();
        } catch (Exception e) {
            throw new RuntimeException("MD%算法不存在",e);
        }
    }
    //user表管理员密码
    @Test
    public void test() {
        System.out.println(md5("123456"));
    }
}
